import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/components/layout/layoutView.vue'
import LayoutEmpty from '@/components/layout/emptyView.vue'
// import HomeView from '../views/HomeView.vue'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
  }
**/

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/account/Login.vue'),
    hidden: true
  },
  {
    path: '/changePassword',
    name: 'ChangePassword',
    component: () => import('@/views/account/password.vue'),
    hidden: true
  },
  {
    path: '/',
    name: 'Root',
    isRoot: true,
    component: Layout,
    children: [
      {
        path: '/',
        name: 'Dashboard',
        component: () => import('@/views/HomeView.vue'),
        meta: {
          title: '首页',
          icon: 'dashboard'
        }
      },
      {
        path: '/list',
        name: 'List',
        component: () => import('@/views/ListView.vue'),
        meta: {
          title: '列表',
          icon: 'list'
        }
      },
      {
        path: '/o',
        name: 'Other',
        component: LayoutEmpty,
        meta: {
          title: '其他',
          icon: 'email'
        },
        children: [
          {
            path: '/about1',
            name: 'About1',
            component: () => import('../views/AboutView.vue'),
            meta: {
              title: '关于1',
              icon: 'dashboard'
            }
          },
          {
            path: '/about2',
            name: 'About2',
            component: () => import('../views/AboutView.vue'),
            meta: {
              title: '关于2',
              icon: 'dashboard'
            }
          }
        ]
      },
      {
        path: '/404',
        name: 'NotFound',
        hidden: true,
        component: () => import('@/views/NotFoundView.vue')
      },
    ]
  },
  {
    path: '/:catchAll(.*)',
    hidden: true,
    redirect: '/404'
  },
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
